import * as zrender from 'zrender';


export class MyCircleShape {
    cx = 0
    cy = 0
    r = 0
}

export interface MyCircleProps extends zrender.PathProps {
    shape?: Partial<MyCircleShape>
}
class MyCircle extends zrender.Path<MyCircleProps> {

    shape: MyCircleShape

    constructor(opts?: MyCircleProps) {
        super(opts);
        super.draggable = true;
    }

    getDefaultShape() {
        return new MyCircleShape();
    }

    buildPath(ctx: CanvasRenderingContext2D, shape: MyCircleShape, inBundle: boolean) {
        // Better stroking in ShapeBundle
        // Always do it may have performence issue ( fill may be 2x more cost)
        if (inBundle) {
            ctx.moveTo(shape.cx + shape.r, shape.cy);
        }
        // else {
        //     if (ctx.allocate && !ctx.data.length) {
        //         ctx.allocate(ctx.CMD_MEM_SIZE.A);
        //     }
        // }
        // Better stroking in ShapeBundle
        // ctx.moveTo(shape.cx + shape.r, shape.cy);
        ctx.arc(shape.cx, shape.cy, shape.r, 0, Math.PI * 2);
    }
};

MyCircle.prototype.type = 'MyCircle';

export default MyCircle;